<?php
include('includes/functions.php');
$event = get_event($_GET['day'],$_GET['month'],$_GET['year'],$_GET['slug']);
$title = $event['title'];
include('includes/header.php');
?>
<script>
	function share() {
		if (document.getElementById('share').style.visibility = 'hidden') {
			document.getElementById('share').style.visibility = 'visible';
		} else {
			document.getElementById('share').style.visibility = 'visible';
		}
	}
</script>
<div class='form-row'>
	<div class='form-label'>
		Date:
	</div>
	<div class='form-field'>
		<?php echo date('l F j, Y',strtotime($event['startdate'])); ?>
		<?php if ($event['allday'] && strtotime($event['startdate']) != strtotime("-1 day",strtotime($event['enddate']))) echo " - " .date('l F j, Y',strtotime("-1 day",strtotime($event['enddate']))); ?>
	</div>
</div>
<?php if (!$event['allday']) { ?>
<div class='form-row'>
	<div class='form-label'>
		Time:
	</div>
	<div class='form-field'>
		<?php echo date('g:i a',strtotime($event['startdate'] ." " . $event['starttime'])); ?>
		 - 
		<?php echo date('g:i a',strtotime($event['startdate'] ." " . $event['endtime'])); ?>
		<?php if ($event['startdate'] != $event['enddate']) { ?>
					 <?php echo date('F j, Y',strtotime($event['enddate'])); ?>

		<?php } ?>
	</div>
</div>
<?php } ?>

<?php $meta_keys = get_meta_keys(); ?>
<?php foreach (get_meta($event['id']) as $key => $meta) { 
	$meta_key = $meta_keys[$key];
	?>
<div class='form-row'>
	<div class='form-label'>
		<?php echo $meta_key['desc'];?>: 
	</div>
	<div class='form-field'>
		<?php echo make_link($meta['value']); ?>
	</div> 
</div>
<?php } ?>
<?php if (strlen($event['desc'])>1) { ?>
<div class='form-row'>
	<div class='form-label'>
		Description: 
	</div>
	<div class='form-field' style='width:200px'>
		<?php echo make_link($event['desc']); ?>
	</div>
</div>
<?php } ?>

<div class='form-row'>
	<div class='form-label'>
		
	</div>
	<div class='form-field'>
		<div class='attrib'><?php echo attribute($event['id']); ?></div>
	</div>
</div>

<div class='clear'> </div>
<?php $date = str_replace("-","/",$event['startdate']); ?>
<div class='links'> [ <a href='javascript:share();'>Share</a>] </div>
<div class='share' style='visibility:hidden' id='share'>
	<a href='/calendar/<?php echo $date . "/" . $event['slug']; ?>/'>Link</a> |
	<a href="http://www.facebook.com/share.php?u=http://www.gwstudentassociation.com<?php echo "/calendar/". $date . "/" . $event['slug']; ?>/">Facebook</a> | 
	<a href="/calendar/<?php echo $date . "/" . $event['slug']; ?>/tweet/">Twitter</a>
</div>

<?php if (!is_logged_in()) { ?>
<div class='edit-prompt'>Is this your event? <a href='/calendar/<?php echo $date . "/" . $event['slug']; ?>/edit/'>Login to edit this event</a></div>
<?php } else {
	if ($_SESSION['UserID'] == $event['user'] | is_admin($_SESSION['UserID'])) { ?>
<div class='edit-prompt'>[ <a href='/calendar/<?php echo $date . "/" . $event['slug']; ?>/edit/'>edit this event</a> ] </div>
	<?php } ?>
<?php } ?>
<?php if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') { 
include('includes/footer.php');
} ?>